Assignment - INPUT DEVICES

Goal

In Input device assignment we have to add a sensor to a microcontroller board we have designed and read data from it.

My final project is a Lux Meter so I am designing, fabricating and assembling an input device board with LDR light sensor. This board will also serve as output device for displaying values of light in LCD display. I also add some buttons. This sensor will sense light and then output an analog signal which will pass through micro-controller. This involves implementation of ADC and other calculations to send data over serial monitor in the computer.

The sensor

For illumination sensor I use a LDR or Light dependant resistance. This device is like a variable resistor that changes resistance according to variation of light. I have attached here the datasheet of LDR sensor. Figure 4 in datasheet shows illumination is linear function of resistance. So resistance is near 1000kOhn when lux is 0.1 and resistance is 0.1 kOhm when illumination is 10000 lux.

1st Step - Board Schematic Design

Board is based in attiny44 microcontroller. LDR light sensor will be attached to analog input 0 located in pin 13 under GND pin (refer to attiny 44 datasheet). I need t add library in in eagle for LDR found in internet, make new schematic project then start design. After schematic design I checked design through 'ERC' command. As suggest error and notification I followed and resolve error.

2nd step - Making of board file in Eagle

In Eagle schematic there is option of 'switch to board' in files. So click on that, new window got opened and all components shown in outer side of box. Take all components in side the box and arrange it properly avoid overlaping. After this process go through routing, connect all components and create path.

Again here I checked error with command 'DRC'and export your board file into '.png' format. Make first file with components in .png and border file as interior.

3rd Step - Milling Process

I have modela MDX20 CNC milling machine. I used fab modules for milling PCB. Selection of cutting, milling bits is very important, use 1/64 bit for milling and 1/32 for drilling and cutting.

4th Step - Milling and finishing Process

While milling on modella machine I faced problem like milling traces not done proper way. 1/64 milling bit got broken. After study I come to know that all these thing happen because of bed level because of remains of double side tape and dirt make board not be leveled. I clean the bed and check level tube and again milling process. I did not cutout the board this time.

5th Step - Soldering Process

After milling I clean board and start soldering on it. Soldering, especially SMD components is always the most struggling part for me. I took 2hrs for solder and debugging.

6th Step - Programming

This time for programming I use Arduino IDE. For programming an attiny with Arduino IDE you need to add microcontroller to the list. I follow tutorial in Hi Lo Tech MIT Media Lab where this is explained link here. Also pin name are different from those used in C program. There is a image showing the equivalences.

The program

Program for input device as per follow. The microcontroller reads analog signal in pin 0. In ADC voltage is internally converted to a value from 0 to 255. Meaning 0 is 0 Volts and 255 equals 5 Volts. Then is this value is sent through the serial monitor every second.

I am starting to implement a converter from voltage to lux accourding to the sensor datasheet. But at this stage is still not implemented. It will be implemented in final project.

After programming My input device LDR start works as sensor
and give light intensity value in terms of digital number. Following is the source code for Input device

Download design files and code Download Eagle files from here.
Final code is here: Original code